<div style="padding:20px;">
<form method="post" action="" />
<?php
 $arrMonth  = array(1=>"Jan",2=>"Feb",3=>"Mar",4=>"Apr",5=>"May",6=>"Jun",7=>"Jul",8=>"Aug",9=>"Sep",10=>"Oct",11=>"Nov",12=>"Dec");
 ?>
<b> Year </b>  <select class="txt1" name="financial_year"> 
		  													<?php 
															/*if(empty($year))
															{
															$count=count($finYears);
															$year  = $finYears[$count-1]['id'];
															} */
															foreach($finYears as $row)
															  {
																  
																  echo "<option ";
																  if($year== $row['id'])
																  echo "selected ";
																  else if(empty($year)){ if($row['flag']==1) echo "selected"; }
																  echo " value=".$row['id'].">". $row['year1'] ." ". $arrMonth[$row['month1']]."-".$row['year2'] ." ". $arrMonth[$row['month2']]."</option>";
																
															  }
		                                                       ?> </select>&nbsp;&nbsp;&nbsp;&nbsp;

&nbsp;&nbsp;&nbsp;&nbsp;<b> Month </b> <?php 
 // print_r($finYears);
  $month= array('1'=>"Jan",'2'=>"Feb",'3'=>"Mar",
		               '4'=>"Apr",'5'=>"May",'6'=>"Jun ",
					   '7'=>"Jul",'8'=>"Aug",'9'=>"Sep",
					   '10'=>"Oct",'11'=>"Nov",'12'=>"Dec"
					   ); 
					   
	?>


        <?php 
		if(empty($mon))
		{
		$current_month= date('m');
		$mon= $current_month-1;
		if($current_month=='12')
		{
			$mon=1;
		}
		}
		//echo $previous_month;
		?>
        
         <select class="txt4" name="month"> 
        <option value="">  Select Month </option>
        <?php 
		foreach($month as $key=>$val)
		{
			echo "<option ";
			if($key==$mon)
			{
				echo "selected";
			}
			echo " value=".$key.">".$val."</option>";
		}
		 ?> </select> 
    
         
      &nbsp;&nbsp;&nbsp;   <input type="submit" value="go" name="search" class="btn_bt" /> 
   
         </form>
           <br/>
       



     <?php
	 //print_r($staff);
	 if(!empty($result))
	 {
		 ?>
<table  id="tbllist">
<tbody>
	<tr>
		<th> Name </th> 
        <th> Code</th>
         <th>  Basic </th> 
       
         <th>  DA Amount</th>
         <th>    HRA Amount </th>
         <th>   Other Allowance </th>
         <th>  Total </th>
          <th>  Provident Fund </th>
         <th>   Life Insurance </th>
         <th>  Misc Recoveries </th>
         <th>   Net Amount Paid </th>
         <th>  Action </th>
     </tr>  
     <?php
	 $i=0;
		 foreach($result as $record)
		 {
			 $i++;
		 ?>
         
         <tr>
         <td>  <?php echo $record['first_name']." ".$record['last_name'];  ?>
         </td>
         <td> <?php echo  $record['staff_code']; ?> </td>
		 <?php
		    if($record['paid']==0) 
			 {
				 echo "<td><form method='post' action=''> "; 
				 echo "<input type='hidden' name='month' value='".$mon."'/>
				        <input type='hidden' name='financial_year' value='".$year."' />
						<input type='hidden' name='staff_id' value='".$record['staff_id']."' />
						".$record['basic_pay']."<input type='hidden' id='basic".$i."' class='txt4' name='basic_pay' value='".$record['basic_pay']."'></td>";
				 
				  /*echo "<td><select class='txt4' name='da_type' id='da_type".$i."'>  <option ";
				  if($record['da_type']=='amount')
				  echo "selected ";
				  echo ">amount</option><option ";
				   if($record['da_type']=='percent')
				 echo "selected ";
				  echo ">percent </option></select></td>"; */
				  if($record['da_type']=='percent')
				  $record['da_amount']= $record['basic_pay']* $record['da_amount']/100;
				  echo "<td> ".$record['da_amount']."<input  type='hidden' class='txt4' name='da_amount' id='da_amount".$i."' value='".$record['da_amount']."'></td>";
				/* echo "<td><select class='txt4' name='hra_type' id='hra_type".$i."'><option ";
				 if($record['hra_type']=='amount')
				 echo "selected ";
				 echo        ">amount </option><option ";
				 if($record['hra_type']=='percent')
				 echo "selected ";
				echo	">percent </option></select>";
				 echo "</td>";*/
				   if($record['hra_type']=='percent')
				  $record['hra_amount']= $record['basic_pay']* $record['hra_amount']/100;
				  echo "<td>".$record['hra_amount']."<input type='hidden' class='txt4' name='hra_amount' id='hra_amount".$i."' value='".$record['hra_amount']."'></td>";
				  echo "<td>".$record['other_allowance']."<input type='hidden' class='txt4' name='other_allowance' id='other_allowance".$i."' value='".$record['other_allowance']."'></td>";
				  echo "<td>".$record['total']."<input type='hidden' class='txt4' name='total' id='total".$i."' value='".$record['total']."' onfocus='Sum(".$i.")'></td>";
				  echo "<td>".$record['pf_amount']."<input type='hidden' class='txt4' name='pf_amount' id='pf_amount".$i."' value='".$record['pf_amount']."'></td>";
				   echo "<td>".$record['life_insurance']."<input type='hidden' class='txt4' id='life_insurance".$i."' name='life_insurance' value='".$record['life_insurance']."'></td>";
				    echo "<td><input type='text' onkeyup='netAmount(".$i.");' class='txt4' id='misc_recoveries".$i."' name='misc_recoveries' value='".$record['misc_recoveries']."'></td>";
					echo "<td><input type='text' id='net_amount_paid".$i."' onfocus='netAmount(".$i.");' class='txt4' name='net_amount_paid' value='".$record['net_amount_paid']."'><td>";
			 }
			 else{
		
			
			
		 ?>  </td> 
      
          <td> <?php echo  $record['basic_pay']; ?> </td>
         
           <td> <?php
		   if($record['da_type']=='percent')
		   $record['da_amount'] =  $record['basic_pay']*$record['da_amount'] /100;
		    echo  $record['da_amount']; ?> </td>
        
            <td> <?php 
			if($record['hra_type']=='percent')
		   $record['hra_amount'] =  $record['basic_pay']*$record['hra_amount'] /100;
			echo  $record['hra_amount']; ?> </td>
             <td> <?php echo  $record['other_allowance']; ?> </td>
             <td> <?php echo  $record['total']; ?> </td>
             <td> <?php echo  $record['pf_amount']; ?> </td>
              <td> <?php echo  $record['life_insurance']; ?> </td>
              <td> <?php echo  $record['misc_recoveries']; ?> </td>
              <td> <?php echo  $record['net_amount_paid']; ?> </td>
              <td> <?php }
			   if($record['paid']==0) 
			  			{
							echo "<input type='submit' name='pay' value='pay'/>";
							echo "</form>";
			  		    }
						elseif($record['paid']==1)
						{
							echo "<img src='".$admin_image_path."icons/apply.png'  alt=''/>";
						}
			        ?> 
                    
              </td>
         </tr>
         <?php
		 }
	 }
	 ?>  


</tbody>
</table>
    
    
     
    
   
 


    

		
       
         
   
   
	
			
		



 </div>
 <script type="text/javascript">//<![CDATA[
      Calendar.setup({
        inputField : "f_dob",
        trigger    : "f_dob_button",
        onSelect   : function() { this.hide() },
        showTime   : 12,
        dateFormat : "%Y-%m-%d"
      });
    //]]></script>
 <script>
 $(document).ready(function() {
     $("#staff_form").RSV({
       onCompleteHandler: frmSubmit,
       errorFieldClass: "errorDesc",
       displayType: "display-html",
       errorHTMLItemBullet: "&#8212; ",
             rules: [
                     "required,basic_pay,Please enter name.",
					 
             ]
     });
  // a custom onComplete handler to prevent form submits for the demo
     function frmSubmit()
     {
       return true;
     }

        
});
 </script>
